﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace FizzBuzzSeqWF
{
	public sealed partial class HelloWorkflow: SequentialWorkflowActivity
	{
		public HelloWorkflow()
		{
			InitializeComponent();
        }

        private void showInstructionActivity_ExecuteCode(object sender, EventArgs e)
        {
            ConsoleColor previousColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*******************************************");
            Console.WriteLine("***** Welcome to the first WF Example *****");
            Console.WriteLine("*******************************************\n");
            Console.WriteLine("I will now ask for your name and validate the data...\n");
            Console.ForegroundColor = previousColor;
            
        }

        public string UserName { get; set; }

        private void GetAndValidateName(object sender, ConditionalEventArgs e)
        {
            Console.Write("Please enter name, which must be less than 10 chars: ");
            UserName = Console.ReadLine();
            // See if name is correct length, and set the result.
            e.Result = (UserName.Length >= 10);
        }

        private void nameNotValid_ExecuteCode(object sender, EventArgs e)
        {
            Console.WriteLine("Sorry, try again...");
        }
	}

}
